/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.web.gwt.basics.client.widget;

import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Label;

/**
 * print a link to an url.
 */
public class TextExternalHyperLink
    extends ExternalHyperLink
    implements HasText
{
  /**
   * the content of the &lt;a&gt; element.
   */
  private final Label label = new Label();



  /**
   * constructor.
   */
  public TextExternalHyperLink()
  {
    super();
    add(label);
  }



  /**
   * constructor.
   * 
   * @param text
   *          the content of the &lt;a&gt; element
   */
  public TextExternalHyperLink(String text)
  {
    super();
    label.setText(text);
    add(label);
  }



  /**
   * constructor.
   * 
   * @param text
   *          the content of the &lt;a&gt; element
   * @param url
   *          the href of the &lt;a&gt; element
   */
  public TextExternalHyperLink(String text, String url)
  {
    super(url);
    label.setText(text);
    add(label);
  }



  /**
   * constructor.
   * 
   * @param text
   *          the content of the &lt;a&gt; element
   * @param url
   *          the href of the &lt;a&gt; element
   * @param target
   *          the target of the &lt;a&gt; element
   */
  public TextExternalHyperLink(String text, String url, String target)
  {
    super(url, target);
    label.setText(text);
    add(label);
  }



  /**
   * getter for the text property.
   * 
   * @return the text
   */
  public String getText()
  {
    return label.getText();
  }



  /**
   * setter for the text property.
   * 
   * @param text
   *          the text to set
   */
  public void setText(String text)
  {
    if (text == null) {
      label.setText("");
      return;
    }
    label.setText(text);
  }

}
